package com.restaurant.application.customer.support;

import com.nebutown.base.ViewSpec;
import com.nebutown.base.data.ViewUpdate;
import com.nebutown.description.data.UnitForGeneration;
import com.nebutown.generation.PickableBean;
import com.nebutown.supporthome.AbstractBase;
import com.nebutown.supporthome.CmdCapsule;
import com.restaurant.application.customer.CustomerImpl;
import com.restaurant.application.indexes.customerlist.mysql.CustomerListBean;

public class CustomerBase extends AbstractBase {
    private UnitForGeneration desc = new UnitForGeneration();

    public AbstractCustomer getImpl() {
        AbstractCustomer inst = new CustomerImpl();
        inst.setBase(this, getEscort());
        return inst;
    }

    @Override
    public CustomerOutFace getUnitFace() {
        return new CustomerOutFace(this);
    }

    @Override
    protected Object callDistr(String name, Object... param) {
        switch(name) {
            case "update": return getImpl().update((CustomerData)param[0]);
            case "init": return getImpl().init((CustomerData)param[0]);
            case "getPersonBO": return getImpl().getPersonBO();
            case "findData":
                return getImpl().findData();
            case "minusScores":
                return getImpl().minusScores((int) param[0]);
            case "plusScores": getImpl().plusScores((int)param[0]); return "";
            case "getMainBO":
                return getImpl().getMainBO();
            case "getId": return getImpl().getId();
            case "getFullView":
                setIsRefresher();
                return getImpl().getFullView();
            case "getViewLead": return getImpl().getViewLead((ViewSpec)param[0]);
            case "getEffectiveInterface":
                return getImpl().getEffectiveInterface();
            case "getCustomerUidDataForCustomerList": return getImpl().getCustomerUidDataForCustomerList((CustomerListBean)param[0]);
        }
        return null;
    }

    @Override
    protected boolean authDistr(String name) {
        switch(name) {
        }
        return true;
    }

    @Override
    public CmdCapsule getUICall(int cmd) {
        switch(cmd) {
            case 0:
                return AbstractCustomer.CMD_MODIFY;
            case 1:
                return AbstractCustomer.CMD_ADDBLACK;
            case 2:
                return AbstractCustomer.CMD_MOVEOUTBLACK;
        }
        return null;
    }

    @Override
    public ViewUpdate uiCall(int cmd, PickableBean param, int... seq) {
        switch(cmd) {
            case 0:
                return getImpl().modify((CustomerData) param, seq);
            case 1:
                return getImpl().addBlack(seq);
            case 2:
                return getImpl().moveOutBlack(seq);
        }
        return null;
    }
}
